package {{package}}

{{#imports}}import {{import}}
{{/imports}}
import org.junit.jupiter.api.Test
{{#reactive}}
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.test.runBlockingTest
{{/reactive}}
{{^useResponseEntity}}
import org.springframework.http.HttpStatus
{{/useResponseEntity}}
{{#useResponseEntity}}
import org.springframework.http.ResponseEntity
{{/useResponseEntity}}

class {{classname}}Test {

    {{#serviceInterface}}
    private val service: {{classname}}Service = {{classname}}ServiceImpl()
    {{/serviceInterface}}
    private val api: {{classname}}Controller = {{classname}}Controller({{#serviceInterface}}service{{/serviceInterface}})
    {{#operations}}
    {{#operation}}

    /**
     * To test {{classname}}Controller.{{operationId}}
     *
     * @throws ApiException
     *          if the Api call fails
     */
    @Test
    fun {{operationId}}Test() {{#reactive}}= runBlockingTest {{/reactive}}{
        {{#allParams}}
        val {{{paramName}}}: {{>optionalDataType}} = TODO()
        {{/allParams}}
        {{#includeHttpRequestContext}}val {{#reactive}}exchange: org.springframework.web.server.ServerWebExchange{{/reactive}}{{^reactive}}request: {{javaxPackage}}.servlet.http.HttpServletRequest{{/reactive}} = TODO(){{/includeHttpRequestContext}}
        val response: {{#useResponseEntity}}ResponseEntity<{{/useResponseEntity}}{{>returnTypes}}{{#useResponseEntity}}>{{/useResponseEntity}} = api.{{operationId}}({{#allParams}}{{{paramName}}}{{^-last}}, {{/-last}}{{/allParams}}{{#includeHttpRequestContext}}{{#hasParams}}, {{/hasParams}}{{#reactive}}exchange{{/reactive}}{{^reactive}}request{{/reactive}}{{/includeHttpRequestContext}})

        // TODO: test validations
    }
    {{/operation}}
    {{/operations}}
}
